package com.doujiang.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.doujiang.domain.Comment;
import com.doujiang.mapper.CommentMapper;
import com.doujiang.service.ICommentService;
import com.doujiang.service.zzqICommentService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 评论管理Service业务层处理
 * 
 * @author 王伟舰
 * @date 2025-07-19
 */
@Service
public class zzqCommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements zzqICommentService
{
    @Override
    public List<Comment> getCommentsByMovieId(Long movieId) {
        return lambdaQuery().eq(Comment::getMovieId, movieId).list();
    }

    @Override
    public List<Comment> getCommentsByUserId(Long userId) {
        return lambdaQuery().eq(Comment::getUserId, userId).list();
    }

    @Override
    public boolean saveComment(Comment comment) {
        comment.serializeLikesJson();
        return save(comment);
    }
    @Override
    public boolean updateById(Comment comment) {
        comment.serializeLikesJson(); // 手动序列化
        return super.updateById(comment);
    }
}
